package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type NacosConfig struct {
	User      string
	Pass      string
	Port      int
	Host      string
	DataId    string
	Group     string
	NacosName string
}

type MySQLConfig struct {
	User string
	Pass string
	Port int
	Host string
	Db   string
}

type ViperData struct {
	MySQLConfig MySQLConfig
	NacosConfig NacosConfig
}

var Conf ViperData

func Appconfig() {
	viper.SetConfigFile("./appconfig/conf.yaml")

	err := viper.ReadInConfig()
	if err != nil {

		fmt.Println("viper配置失败")
		panic(err)
		return
	}

	fmt.Println("viper配置成功")

	viper.Unmarshal(&Conf)
}
